 /*///////////////////////////////////////////////////////////////////////////////
-- Author:      liuhx
-- Created:     Mon Aug 26 17:25:15 CST 2019
-- Description:
-- If you have any question,please email to liuhx@gentlesoft.com.cn
////////////////////////////////////////////////////////////////////////////////*/
package com.ctsi.question.service;

 import com.ctsi.commons.util.UtilValidate;
 import com.ctsi.commons.util.id.UUIDGenerator;
 import com.ctsi.commons.util.response.Page;
 import com.ctsi.framework.mybatis.support.MybatisGenericDao;
 import com.ctsi.question.entity.DayReportEntity;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;

 import java.util.List;
 import java.util.Map;


/**
 * 日报表 Service 类
 * @author   liuhx
 * @description  日报表
 * @created	 Mon Aug 26 17:25:16 CST 2019
 */

@Service
public class DayReportEntityService {
	private static final Logger logger=LoggerFactory.getLogger(DayReportEntityService.class);
	@Autowired
	private MybatisGenericDao dao;

	/**
	 * 添加
	 */
	public int insertDayReportEntity(DayReportEntity dayReportEntity){
		if(UtilValidate.isEmpty(dayReportEntity.getId()))
			dayReportEntity.setId(UUIDGenerator.getId());
		logger.debug("insert {}",dayReportEntity);
		return dao.insert(dayReportEntity);
	}
	/**
	 * 动态更新
	 */
	public int updateDayReportEntityByPKSelective(DayReportEntity dayReportEntity){
		logger.debug("updateByPrimaryKeySelective {}",dayReportEntity);
		return dao.update(DayReportEntity.class.getName()+".updateByPrimaryKeySelective", dayReportEntity);
	}
	/**
	 * 更新
	 */
	public int updateDayReportEntity(DayReportEntity dayReportEntity){
		logger.debug("update {}",dayReportEntity);
		return dao.update(dayReportEntity);
	}

	/**
	 * 查询ID
	 * @param id
	 * @return selectPersonId
	 */
	public Map<String,Object> selectID(String id){
		if(UtilValidate.isEmpty(id))
			return null;
		logger.debug("selectPersonId {}",id);
		return (Map<String, Object>) dao.queryForObject(DayReportEntity.class.getName()+".selectPersonId", id);
	}


	public DayReportEntity editDayReportEntityById(String id){
		if(UtilValidate.isEmpty(id))
			return null;
		logger.debug("editById {}",id);
		return (DayReportEntity)dao.queryForObject(DayReportEntity.class.getName()+".edit", id);
	}
	/**
	 * 根据ID查找 DayReportEntity对象
	 */
	public DayReportEntity findDayReportEntityById(String id){
		if(UtilValidate.isEmpty(id))
			return null;
		logger.debug("findById {}",id);
		return dao.get(DayReportEntity.class, id);
	}
	/**
	 * 删除DayReportEntity对象
	 */
	public int removeDayReportEntity(String id){
		if(UtilValidate.isNotEmpty(id))
			return dao.delete(DayReportEntity.class.getName()+".delete", id);
			//return dao.remove(id);
		return 0;
	}

	/**
	 * 详细页查询
	 */
	public DayReportEntity findByDetail(String id){
		return (DayReportEntity)dao.queryForObject(DayReportEntity.class.getName()+".findByDetail",id);
	}
	/**
	 * 多条件查询结果
	 */
	public Page<DayReportEntity> findByMulitCondition(Map<String,Object> param ,int start ,int pageSize){
		logger.debug("findByMulitCondition {}",param);
		if(pageSize<0||pageSize>2000)
			pageSize= Page.DEFAULT_PAGE_SIZE;
		if(start!=-1)
			return dao.queryPage(DayReportEntity.class.getName()+".selectMulitCondition", param, start, pageSize);
		else{
			throw new RuntimeException("参数不正确 !!");
		}
	}

	/**
	 * 领导日报督察 selectMulitConditionLeader
	 */
	public Page<DayReportEntity> selectMulitConditionLeader(Map<String,Object> param ,int start ,int pageSize){
		logger.debug("selectMulitConditionLeader {}",param);
		if(pageSize<0||pageSize>2000)
			pageSize= Page.DEFAULT_PAGE_SIZE;
		if(start!=-1)
			return dao.queryPage(DayReportEntity.class.getName()+".selectMulitConditionLeader", param, start, pageSize);
		else{
			throw new RuntimeException("参数不正确 !!");
		}
	}

	/**
	 * 多条件查询结果不分页
	 */
	public List<DayReportEntity> find(Map<String,Object> map){
		logger.debug("find {}",map);
		return (List<DayReportEntity>)dao.queryForList(DayReportEntity.class.getName()+".selectByMap",map);
	}

}
